home *** CD-ROM | disk | FTP | other *** search
Visual Basic class definition | 2000-12-28 | 7.3 KB | 227 lines |
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "clsProgressBar"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- Option Explicit
-
- Dim m_TextBefore As String
- Dim m_TextAfter As String
-
- Dim m_ShowStatus As Boolean
- Dim m_bHorizontal As Boolean
- Dim m_bBackwards As Boolean
- Dim m_BackColor As Long
- Dim m_ForeColor As Long
-
-
- Public Property Get Horizontal() As Boolean
- Horizontal = m_bHorizontal
- End Property
- Public Property Let Horizontal(ByVal New_Horizontal As Boolean)
- m_bHorizontal = New_Horizontal
- End Property
-
- Public Sub ProgressSteppedBar(picProgress As PictureBox, ByVal Part As Single, ByVal Whole As Single)
- Dim Counter As Integer, x As Integer, y As Integer
- Dim lTextTop As Long
- Dim lTextWidth As Long
- Dim iPercent As Single
-
- With picProgress
- .BorderStyle = 0
- .AutoRedraw = True
- .DrawMode = 13 '// Copy Pen
- .ScaleMode = 3
- .BackColor = m_BackColor
- .ForeColor = m_ForeColor
- .FontBold = True
- .Visible = True
- End With
-
- Counter = 10
- If Part > 0 And Whole > 0 Then
- iPercent = CSng(Part) / CSng(Whole)
- If m_bHorizontal Then
- For x = 3 To iPercent * (picProgress.ScaleWidth - 6) Step 3
- y = x
- If m_bBackwards Then y = picProgress.ScaleWidth - 6 - x
- Counter = Counter + 3
- If Counter >= 8 Then
- picProgress.Line (y, 3)-(y + 6, picProgress.ScaleHeight - 4), picProgress.ForeColor, BF
- Counter = 0
- End If
- Next x
- Else
- For x = 3 To iPercent * (picProgress.ScaleHeight - 6) Step 3
- y = picProgress.ScaleHeight - 6 - x
- If m_bBackwards Then y = x
- Counter = Counter + 3
- If Counter >= 8 Then
- picProgress.Line (3, y)-(picProgress.ScaleWidth - 4, y + 6), picProgress.ForeColor, BF
- Counter = 0
- End If
- Next x
- End If
- End If
-
- '/* Draw 3D boarder */
- picProgress.DrawMode = 13 '/* Copy Pen
- picProgress.Line (0, 0)-(picProgress.ScaleWidth, picProgress.ScaleHeight), vb3DDKShadow, B
- picProgress.Line (1, picProgress.ScaleHeight - 1)-(picProgress.ScaleWidth, picProgress.ScaleHeight - 1), vb3DHighlight
- picProgress.Line (picProgress.ScaleWidth - 1, 1)-(picProgress.ScaleWidth - 1, picProgress.ScaleHeight), vb3DHighlight
-
- picProgress.Refresh
-
- End Sub
- Public Sub ProgressBar(picStatus As PictureBox, ByVal Part As Single, ByVal Whole As Single)
- Dim fPercent As Single
- Dim iX As Integer
- Dim iY As Integer
- Dim iWidth As Integer
- Dim iHeight As Integer
- Dim sCaption As String
-
- On Local Error Resume Next
- With picStatus
- .AutoRedraw = True
- .ScaleMode = 1
- .BorderStyle = 0
- .BackColor = m_BackColor
- .ForeColor = m_ForeColor
- .FontBold = False
- .Visible = True
- End With
-
- If Whole > 0 Then
- '/* calculate the percentage from current value and total value
- fPercent = Part / Whole
- If m_ShowStatus Then
- sCaption = CStr(Part) & " of " & CStr(Whole) & Format(fPercent, " (0%)")
- End If
- Else
- fPercent = 0
- End If
- sCaption = IIf(m_TextBefore > vbNullString, m_TextBefore & " ", vbNullString) & sCaption & IIf(m_TextAfter > vbNullString, " " & m_TextAfter, vbNullString)
-
- iWidth = picStatus.TextWidth(sCaption)
- iHeight = picStatus.TextHeight(sCaption)
-
- '/* Now set iX and iY to the starting location for printing the percentage
- iX = (picStatus.ScaleWidth / 2) - (iWidth / 2)
- iY = (picStatus.ScaleHeight / 2) - (iHeight / 2)
-
- '/* Need to draw a filled box with the picStatus background color to wipe out previous
- '/* percentage display (if any)
- picStatus.DrawMode = 13 '/* Copy Pen
- picStatus.Line (iX, iY)-(iWidth, iHeight), picStatus.BackColor
-
- '/* Back to the center pri position and pri the text
- picStatus.CurrentX = iX
- picStatus.CurrentY = iY
- picStatus.Print sCaption
-
- '/* Now fill in the box with the ribbon color to the desired percentage
- '/* Use the "Not XOR" pen so that we change the color of the text to white
- '/* wherever we touch it, and change the color of the background to blue
- '/* wherever we touch it.
- picStatus.DrawMode = 10 '/* Not XOR Pen
- If m_bHorizontal Then
- If fPercent > 0 Then
- If m_bBackwards Then
- picStatus.Line (picStatus.Width, 0)-(picStatus.Width - (picStatus.Width * fPercent), picStatus.Height), picStatus.ForeColor, BF
- Else
- picStatus.Line (0, 0)-(picStatus.Width * fPercent, picStatus.Height), picStatus.ForeColor, BF
- End If
- End If
- Else
- If fPercent > 0 Then
- If m_bBackwards Then
- picStatus.Line (0, 0)-(picStatus.Width, picStatus.Height * fPercent), picStatus.ForeColor, BF
- Else
- picStatus.Line (0, picStatus.Height)-(picStatus.Width, picStatus.Height - (picStatus.Height * fPercent)), picStatus.ForeColor, BF
- End If
- End If
- End If
-
- '/* Draw 3D boarder */
- picStatus.DrawMode = 13 '/* Copy Pen
- picStatus.ScaleMode = 3
- picStatus.Line (0, 0)-(picStatus.ScaleWidth, picStatus.ScaleHeight), vb3DDKShadow, B
- picStatus.Line (1, picStatus.ScaleHeight - 1)-(picStatus.ScaleWidth, picStatus.ScaleHeight - 1), vb3DHighlight
- picStatus.Line (picStatus.ScaleWidth - 1, 1)-(picStatus.ScaleWidth - 1, picStatus.ScaleHeight), vb3DHighlight
- picStatus.Refresh
-
- On Local Error GoTo 0
-
- End Sub
-
- Public Property Let Backwards(ByVal New_Backwards As Boolean)
- m_bBackwards = New_Backwards
- End Property
- Public Property Get Backwards() As Boolean
- Backwards = m_bBackwards
- End Property
-
- Private Sub Class_Initialize()
-
- m_BackColor = vbWindowBackground
- m_ForeColor = vbHighlight
-
- m_TextBefore = vbNullString
- m_TextAfter = vbNullString
-
- m_bHorizontal = True
- m_ShowStatus = True
-
- End Sub
-
-
- Public Property Get TextBefore() As String
- TextBefore = m_TextBefore
- End Property
-
- Public Property Let TextBefore(ByVal vNewValue As String)
- m_TextBefore = TextBefore
- End Property
-
- Public Property Get TextAfter() As String
- TextAfter = m_TextAfter
- End Property
-
- Public Property Let TextAfter(ByVal vNewValue As String)
- m_TextAfter = vNewValue
- End Property
-
- Public Property Get BackColor() As Long
- BackColor = m_BackColor
- End Property
-
- Public Property Let BackColor(ByVal vNewValue As Long)
- m_BackColor = vNewValue
- End Property
-
- Public Property Get ForeColor() As Long
- ForeColor = m_ForeColor
- End Property
-
- Public Property Let ForeColor(ByVal vNewValue As Long)
- m_ForeColor = vNewValue
- End Property
-
- Public Property Get ShowStatus() As Boolean
- ShowStatus = m_ShowStatus
- End Property
-
- Public Property Let ShowStatus(ByVal vNewValue As Boolean)
- m_ShowStatus = vNewValue
- End Property
-